<?php

namespace app\mobile\controller;

use think\Controller;
use think\Request;
use think\Db;
class Design extends Controller
{
   public function index()
   {
    $list=Db::table('xo_mobile_design')->field(true)->order('views desc')->select();
       return view('design/index',['list'=>$list]);
   }

   public function detail()
   {
	$data = input('get.');
	$id = $data['id'];
    $list=Db::table('xo_mobile_design')->where('id',$id)->field(true)->find();
    // 浏览量 +1
    // 并写入数据库
    $num = $list['views'];
    $num +=1;
    $list['views'] = $num;
    $res = Db::table('xo_mobile_design')->where('id',$id)->update($list);
    if (!$res) {
    	return $this->error('网络错误,请稍后再试~');
    }
    return view('design/detail',['list'=>$list]);
   }
}
